package com.neuedu.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neuedu.domain.Collectioninfo;
import com.neuedu.domain.Userinfo;
import com.neuedu.service.ArticleService;
import com.neuedu.service.impl.ArticleServiceImpl;

//@WebServlet("/article/nocollects")
public class ArticleNoCollectsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String articleid = request.getParameter("articleid");
		Userinfo user = (Userinfo)request.getSession().getAttribute("login_user");
		int id = user.getId();
		Collectioninfo coll = new Collectioninfo();
		coll.setArticleid(Integer.parseInt(articleid));
		coll.setUserid(id);
		ArticleService as = new ArticleServiceImpl();
		int count = as.nocollects(coll);
		response.getWriter().print(count);
		
	}

}
